﻿using System;
namespace Producers.Rr.Xtee.Riik.Ee.Producer.Rr {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="RR48Response_v1", Namespace="http://producers.rr.xtee.riik.ee/producer/rr", Target=typeof(RR48ResponseV1))]
    public class RR48ResponseV1Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IRR48ResponseV1 clazz;
        
        public RR48ResponseV1Serializer(IRR48ResponseV1 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("Isikukood");
            if (clazz.Isikukood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukood))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukood");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikupnimi");
            if (clazz.Isikupnimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikupnimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikupnimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuenimi");
            if (clazz.Isikuenimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuenimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuenimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuolek");
            if (clazz.Isikuolek!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuolek))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuolek");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikusurmakp");
            if (clazz.Isikusurmakp!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikusurmakp))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikusurmakp");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuriik");
            if (clazz.Isikuriik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuriik))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuriik");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikumaak");
            if (clazz.Isikumaak!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikumaak))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikumaak");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuvald");
            if (clazz.Isikuvald!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuvald))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuvald");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuasula");
            if (clazz.Isikuasula!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuasula))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuasula");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikuvaikekoht");
            if (clazz.Isikuvaikekoht!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikuvaikekoht))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikuvaikekoht");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikutn");
            if (clazz.Isikutn!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikutn))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikutn");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikunimi");
            if (clazz.Isikunimi!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikunimi))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikunimi");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikumaja");
            if (clazz.Isikumaja!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikumaja))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikumaja");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Isikukrt");
            if (clazz.Isikukrt!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Isikukrt))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Isikukrt");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("Veakood");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Veakood))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("veatekst");
            if (clazz.Veatekst!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Veatekst))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Veatekst");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Isikukood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikukood");
                }
                clazz.Isikukood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikukood", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikupnimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikupnimi");
                }
                clazz.Isikupnimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikupnimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikupnimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuenimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikuenimi");
                }
                clazz.Isikuenimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuenimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikuenimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuolek") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikuolek");
                }
                clazz.Isikuolek = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuolek")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikuolek", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikusurmakp") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikusurmakp");
                }
                clazz.Isikusurmakp = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikusurmakp")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikusurmakp", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuriik") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikuriik");
                }
                clazz.Isikuriik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuriik")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikuriik", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikumaak") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikumaak");
                }
                clazz.Isikumaak = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikumaak")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikumaak", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuvald") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikuvald");
                }
                clazz.Isikuvald = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuvald")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikuvald", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuasula") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikuasula");
                }
                clazz.Isikuasula = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuasula")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikuasula", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikuvaikekoht") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikuvaikekoht");
                }
                clazz.Isikuvaikekoht = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikuvaikekoht")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikuvaikekoht", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikutn") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikutn");
                }
                clazz.Isikutn = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikutn")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikutn", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikunimi") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikunimi");
                }
                clazz.Isikunimi = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikunimi")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikunimi", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikumaja") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikumaja");
                }
                clazz.Isikumaja = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikumaja")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikumaja", Reader.LocalName);
            }
            if (Reader.LocalName=="Isikukrt") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Isikukrt");
                }
                clazz.Isikukrt = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Isikukrt")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Isikukrt", Reader.LocalName);
            }
            if (Reader.LocalName=="Veakood") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>Veakood");
                }
                clazz.Veakood = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("Veakood")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>Veakood", Reader.LocalName);
            }
            if (Reader.LocalName=="veatekst") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>RR48Response_v1>veatekst");
                }
                clazz.Veatekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("veatekst")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>RR48Response_v1>veatekst", Reader.LocalName);
            }
        }
    }
}
